package org.lc.solon.cmd.util;

import org.noear.solon.Solon;
import org.noear.solon.core.BeanWrap;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class BeanUtil {
    @SuppressWarnings("unchecked")
    public static <T> List<T> sortedBeans(Class<T> clazz) {
        return (List<T>) Solon.context().getWrapsOfType(clazz).stream().sorted(Comparator.comparingInt(BeanWrap::index))
                .map(BeanWrap::raw).collect(Collectors.toList());
    }
}
